package com.asset.dispoal.menu.service;

import com.asset.dispoal.menu.api.GbMenuService;
import com.asset.dispoal.menu.dto.requset.GbMenuRequest;
import com.asset.dispoal.menu.dto.response.GbMenuResponse;
import com.asset.dispoal.menu.service.commom.CompanyMenuCommand;
import com.asset.dispoal.menu.service.commom.DefaultRoleMenuCommand;
import com.asset.dispoal.menu.service.commom.DeleteMenuCommand;
import com.asset.dispoal.menu.service.commom.InsertMenuCommand;
import com.asset.dispoal.menu.service.commom.QueryMenuCommand;
import com.asset.dispoal.menu.service.commom.QueryRoleMenuCommand;
import com.asset.dispoal.menu.service.commom.SelectMenuCommand;
import com.asset.dispoal.menu.service.commom.UpdateMenuCommand;
import com.asset.dispoal.role.dto.GbRoleRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.mhuang.pacebox.springboot.protocol.Result;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 菜单表服务接口
 *
 * @author: mhuang
 * @date: 2022-02-25 15:34:43
 */
@Service
public class GbMenuServiceImpl implements GbMenuService {

    @Autowired
    QueryRoleMenuCommand queryRoleMenuCommand;

    @Autowired
    DeleteMenuCommand deleteMenuCommand;

    @Autowired
    InsertMenuCommand insertMenuCommand;

    @Autowired
    UpdateMenuCommand updateMenuCommand;

    @Autowired
    SelectMenuCommand selectMenuCommand;


    @Autowired
    QueryMenuCommand queryMenuCommand;
    @Autowired
    CompanyMenuCommand companyMenuCommand;


    @Autowired
    DefaultRoleMenuCommand defaultRoleMenuCommand;

    @Override
    public void insert(GbMenuRequest request) {
        insertMenuCommand.execute(request);
    }

    @Override
    public void delete(String id) {
        deleteMenuCommand.execute(id);
    }

    @Override
    public void update(GbMenuRequest request) {
        updateMenuCommand.execute(request);
    }

    @Override
    public Result<List<GbMenuResponse>> queryTreeAll(GbMenuRequest request) {
        return queryMenuCommand.execute();
    }

    @Override
    public Result selectMenu(List<String> ids) {
        return selectMenuCommand.execute(ids);
    }

    @Override
    public Result<List<GbMenuResponse>> companyMenu(String companyType) {
        Map<String, String> map = new HashMap<>(1);
        map.put("companyType", companyType);
        return companyMenuCommand.execute(map);
    }

    @Override
    public Result<List<GbMenuResponse>> companyMenuById(String companyId) {
        Map<String, String> map = new HashMap<>(1);
        map.put("companyId", companyId);
        return companyMenuCommand.execute(map);
    }

    @Override
    public Result<List<GbMenuResponse>> defaultRoleMenu(String role, String companyType) {
        Map<String, String> map = new HashMap<>(2);
        map.put("role", role);
        map.put("companyType", companyType);
        return defaultRoleMenuCommand.execute(map);
    }

    @Override
    public Result<List<GbMenuResponse>> roleMenu(GbRoleRequest role) {
        return queryRoleMenuCommand.execute(role);

    }


}